package com.mstore.service;

import java.util.ArrayList;
import java.util.List;

import com.mstore.dao.BroadcastDao;
import com.mstore.pojo.Broadcast;

public class BroadcastService {

	private BroadcastDao broadcastDao;

	/**
	 * 新增消息通知
	 */
	public void addBroadcast(Broadcast broadcast) {
		broadcastDao.addBroadcast(broadcast);
	}

	/**
	 * 删除消息通知
	 */
	public void delBroadcast(Broadcast broadcast) {
		broadcastDao.delBroadcast(broadcast);
	}

	/**
	 * 修改消息通知
	 */
	public void modifyBroadcast(Broadcast broadcast) {
		broadcastDao.modifyBroadcast(broadcast);
	}

	/**
	 * 分页查询企业的消息
	 */
	public List<Broadcast> getBroadcastByPage(int index, long eaId) {
		List<Broadcast> broadcasts = new ArrayList<Broadcast>();
		List<Object> objects = broadcastDao.getBroadcastByPage(index, eaId);
		for (Object object : objects) {
			broadcasts.add((Broadcast) object);
		}
		return broadcasts;
	}

	/**
	 * 查询一条通知
	 */
	public Broadcast getBroadcastById(Long id) {
		Object object = broadcastDao.getBroadcastById(id);
		if (object == null) {
			return null;
		}
		return (Broadcast) object;
	}

	/**
	 * 获取企业的消息总数
	 */
	public int getCountBroadcastByEaId(Long eaId) {
		return broadcastDao.getCountBroadcastByEaId(eaId);
	}

	/**
	 * 条件查询消息
	 */
	public List<Broadcast> getBroadcastByConditions(Broadcast broadcast) {
		List<Broadcast> broadcasts = new ArrayList<Broadcast>();
		List<Object> objects = broadcastDao.getBroadcastByConditions(broadcast);
		for (Object object : objects) {
			broadcasts.add((Broadcast) object);
		}
		return broadcasts;
	}

	public BroadcastDao getBroadcastDao() {
		return broadcastDao;
	}

	public void setBroadcastDao(BroadcastDao broadcastDao) {
		this.broadcastDao = broadcastDao;
	}

}
